<?php

if(!defined('IN_NETGORESP')){ exit; }

 /*
   ----------------------------------------------------------------------------------------------------
   INCLUSIONS
   ----------------------------------------------------------------------------------------------------
	+ core/class_database.php
		@ File: Contains functions to control the database
	+ core/class_template.php
		@ File: Contains functions to create the template
	+ core/class_cookies.php
		@ File: Contains functions to manage the login / logout cookies
	+ core/functions.php
		@ File: Contains all the other functions needed.
	+ config.php
		@ File: Contains easy to edit variables for the sites needs.
	+ connect.php
		@ File: Contains the database configuration settings.
	+ Lanuage file
		@ File: Contains various words / strings used widely in the site.
   ----------------------------------------------------------------------------------------------------
   */
   
 require('core/class_database.php');
 require('core/class_template.php');
 require('core/class_cookies.php');
 require('core/functions.php');  
 require('config.php');  
 require('connect.php');    
 require('lang/lang_'.$config['language'].'.php');



 /*
   ----------------------------------------------------------------------------------------------------
   STRIPSLASHES & ADDSLASHES & HTML CONVERSION
   ----------------------------------------------------------------------------------------------------
	+ Check for magic_quotes
		+ If true:
			- Strip all slashes deep
		+ Else:
			- Strip and HTML Deep them.
   ----------------------------------------------------------------------------------------------------
   */
 if (get_magic_quotes_gpc()) 
 {
   	$_POST = array_map('stripslashes_deep', $_POST);
   	$_GET = array_map('stripslashes_deep', $_GET);
   	$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
 }
 
 $_POST = array_map('addslashes_deep', $_POST);
 $_GET = array_map('addslashes_deep', $_GET);
 $_GET = array_map('html_deep', $_GET);
 $_COOKIE = array_map('addslashes_deep', $_COOKIE);
 $_COOKIE = array_map('html_deep', $_COOKIE);

 /*
   ----------------------------------------------------------------------------------------------------
   INITIATE CLASSES NEEDED
   ----------------------------------------------------------------------------------------------------
	+ $db
		@ Class: Database function operations
	+ $cookie
		@ Class: Cookie control
	+ $template
		@ Class: Template class to create / control the template
   ----------------------------------------------------------------------------------------------------
   */
 $db		  	= new db();
 $cookie		= new cookie();
 $template	= new template();

 /*
   ----------------------------------------------------------------------------------------------------
   CONNECTING TO DATABASE
   ----------------------------------------------------------------------------------------------------
	+ Check to see if "connect.php" was edited!
		+ If not:
			- Send template error!
		+ Else
			+ Connect to the database
				+ If you can't connect:
					- Send Template Error with reason.
   ----------------------------------------------------------------------------------------------------
   */
   
   
   
 if ($dbsettings['user'] == "MySql_root" or 
     $dbsettings['pass'] == "MySql_password" or
     $dbsettings['name'] == "MySql_DBName") 
 {
 	  die($template->error($lang['mConnectionError'], 'You have not edited <strong style="color:red">connect.php</strong> fully. Default dummy settings exist.'));
 }

 // Connect to Database
 $db->mysql_connect($dbsettings['server'], $dbsettings['user'], $dbsettings['pass'], $dbsettings['name'], $dbsettings['port']);

 
/*
 ----------------------------------------------------------------------------------------------------
 CONFIGURATION CHECK
 ----------------------------------------------------------------------------------------------------
+ Check configuration "edited" setting
	+ If it hasn't been changed
		- Send template error telling them to edit the config.
 ----------------------------------------------------------------------------------------------------
 */
if($config['edited'] == 0)
{ 
	die($template->error($lang['cError'], $lang['cConfig']));
}

// We do not need this any longer, unset for safety purposes
unset($dbsettings['pass']);

// Check Cookies
$userinfo = $cookie->parse_cookie($db, $template);

// Check Users Online
$users_online = getUsersOnline($db);

// Create Navigation Menu
$navigation = $template->create_nav($userinfo,$link,$users_online,$lang);

?>